﻿<UserControl x:Class="EventLogAnalyzer.View.LogDistributionControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:Converter="clr-namespace:EventLogAnalyzer.View.Converter" mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="1300" Height="360" MouseDown="UserControl_MouseDown">
    <UserControl.Resources>
        <Converter:LogCountToHeightConverter x:Key="logCountHeightConverter"/>
        <Converter:EventLogGroupsCountToWidthConverter x:Key="eventLogGroupsCountToWidthConverter"/>
        <Converter:BoolToVisibilityConverter x:Key="boolToVisibilityConverter"/>
    </UserControl.Resources>
    <Grid>        
        
        <Border Canvas.Left="0" Canvas.Top="0" x:Name="border"  BorderThickness="1" CornerRadius="30" Background="Black" Opacity="0.9" ClipToBounds="True" Height="360" BorderBrush="#FF726565" HorizontalAlignment="Stretch" VerticalAlignment="Top">
            <Border.Triggers>
                <EventTrigger RoutedEvent="UserControl.Loaded">
                    <BeginStoryboard >
                        <Storyboard>
                            <DoubleAnimation
                                Storyboard.TargetName="border" 
                                Storyboard.TargetProperty="Height"
                                From="10" To="360" Duration="0:0:0.400" />
                        </Storyboard>
                    </BeginStoryboard>
                </EventTrigger>
            </Border.Triggers>
        </Border>
        <Grid Margin="10,10,10,10" VerticalAlignment="Top" HorizontalAlignment="Stretch">
            <Grid.RowDefinitions>
                <RowDefinition Height="40" />
                <RowDefinition Height="260" />
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <TextBlock Foreground="Gold" Grid.Column="0" FontSize="19" Margin="20,0,0,0" Text="Search: " Grid.Row="0"/>
            <TextBox Foreground="Gold" Grid.Column="1" Margin="100,5,0,0" Width="130" HorizontalAlignment="Left" VerticalAlignment="Top" Grid.Row="0" Text="{Binding Path=SearchText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Background="Transparent" Height="25" IsHitTestVisible="True"/>
            <Rectangle Grid.Row="1" Fill="Black" />
            <ItemsControl Grid.Row="1"  ItemsSource="{Binding Path=YAxisLabels}" VerticalAlignment="Top" Margin="20,20,0,0" HorizontalAlignment="Left">
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" >
                            <TextBlock Text="{Binding}" Foreground="White" FontFamily="Century Gothic" FontSize="10" Height="40" VerticalAlignment="Top"/>
                            <TextBlock Text=" ___" Foreground="White" FontFamily="Century Gothic" FontSize="10" Height="40" Margin="0,-10,0,0" VerticalAlignment="Top"/>
                        </StackPanel>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <StackPanel />
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
            </ItemsControl>
            <ItemsControl Grid.Row="1"  ItemsSource="{Binding Path=XAxisLabels}" VerticalAlignment="Top" Margin="60,222,0,0" HorizontalAlignment="Left">
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Vertical" HorizontalAlignment="Left" VerticalAlignment="Top">
                            <TextBlock Text="|" Foreground="White" FontFamily="Century Gothic" FontSize="10" Width="100" Margin="0,-5,0,0" VerticalAlignment="Top"/>
                            <TextBlock Text="{Binding}" Foreground="White" FontFamily="Century Gothic" FontSize="10" Width="100" Margin="-5,20,0,0" VerticalAlignment="Top">
                                <TextBlock.RenderTransform>
                                    <RotateTransform Angle="-30" />
                                </TextBlock.RenderTransform>
                            </TextBlock>
                        </StackPanel>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <StackPanel Orientation="Horizontal"/>
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
            </ItemsControl>

            <ItemsControl Grid.Row="1" ItemsSource="{Binding Path=EventLogsGroup}" Margin="55,19,0,41">
            <ItemsControl.ItemTemplate>
                <DataTemplate>
                        <Grid>
                            <Rectangle Height="{Binding Path=LogsCountMatchingSearchCriteria, Converter={StaticResource logCountHeightConverter}}" Width="{Binding Path=TotalNumOfGroups, Converter={StaticResource eventLogGroupsCountToWidthConverter}}" Fill="Green" VerticalAlignment="Bottom" MouseDown="Rectangle_MouseDown" MouseRightButtonDown="Rectangle_MouseRightButtonDown"/>
                            <Rectangle Height="{Binding Path=LogsCount, Converter={StaticResource logCountHeightConverter}}" Stroke="White" Fill="Transparent" StrokeThickness="1" Width="{Binding Path=TotalNumOfGroups, Converter={StaticResource eventLogGroupsCountToWidthConverter}}" VerticalAlignment="Bottom" IsHitTestVisible="False"/>
                            <Rectangle Height="{Binding Path=LogsCount, Converter={StaticResource logCountHeightConverter}}" Stroke="Black" Fill="White" StrokeThickness="1" Width="{Binding Path=TotalNumOfGroups, Converter={StaticResource eventLogGroupsCountToWidthConverter}}" VerticalAlignment="Bottom" Visibility="{Binding Path=IsNotFiltered, Converter={StaticResource boolToVisibilityConverter}}" MouseDown="Rectangle_MouseDown" MouseRightButtonDown="Rectangle_MouseRightButtonDown"/>
                        </Grid>
                    </DataTemplate>
            </ItemsControl.ItemTemplate>
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <StackPanel Orientation="Horizontal"/>
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
        </ItemsControl>
            <Line Grid.Row="1"  X1="50" X2="50" Y1="10" Y2="380" Stroke="Yellow"/>
            <Line Grid.Row="1"  X1="20" X2="1300" Y1="220" Y2="220" Stroke="Yellow"/>

            <RadioButton Grid.Row="2" Width="100" HorizontalAlignment="Left" Name="byDate" Checked="byDate_Checked"  Content="Date" Foreground="Gold" FontSize="14" Margin="325,19,-125,6" />
            <RadioButton Grid.Row="2" Width="100" HorizontalAlignment="Left" Name="byOccurrances" Checked="byOccurrances_Checked"  Content="Occurances" Foreground="Gold" FontSize="14" Margin="194,19,106,-14" />
            <RadioButton Grid.Row="2" Width="120" HorizontalAlignment="Left" Name="bySearch" Checked="bySearch_Checked"  Content="Search Criteria" Foreground="Gold" FontSize="14" Margin="456,19,106,-14" />
            <TextBlock FontSize="14" Foreground="Gold" Margin="79,19,-59,-19" Text="Sort X-axis by -> " Grid.Row="2" Width="110" HorizontalAlignment="Left"/>

            <Rectangle Height="24" HorizontalAlignment="Left" Margin="586,7,0,0" Name="rectangle1" Stroke="White" Fill="White" VerticalAlignment="Top" Width="23" />
            <TextBlock Foreground="Gold" Grid.Column="0" FontSize="14" Margin="620,10,0,0" Text="All Logs" Grid.Row="0"/>
            <Rectangle Height="24" HorizontalAlignment="Left" Margin="700,7,0,0" Name="rectangle2" Stroke="White" Fill="Green" VerticalAlignment="Top" Width="23" />
            <TextBlock Foreground="Gold" Grid.Column="0" FontSize="14" Margin="735,10,0,0" Text="Logs matching search criteria" Grid.Row="0"/>
            <Rectangle Height="24" HorizontalAlignment="Left" Margin="965,7,0,0" Name="rectangle3" Stroke="White" Fill="Transparent" VerticalAlignment="Top" Width="23" />
            <TextBlock Foreground="Gold" Grid.Column="0" FontSize="14" Margin="1000,10,0,0" Text="Logs not matching search criteria" Grid.Row="0"/>
        </Grid>

    </Grid>
</UserControl>
